package com.springboot.chongwu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.chongwu.entity.Lunbotu;
import com.springboot.chongwu.mapper.LunbotuMapper;
import com.springboot.chongwu.qpage.QPage;
import com.springboot.chongwu.service.ILunbotuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.chongwu.util.ResultView;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 轮播图 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-09-25
 */
@Service
public class LunbotuServiceImpl extends ServiceImpl<LunbotuMapper, Lunbotu> implements ILunbotuService {


    /**
     * 列表
     * @param qPage
     * @param obj
     * @return
     */
    @Override
    public ResultView getPageList(QPage qPage, Lunbotu obj) {
        IPage iPage = new Page(qPage.getOffset(), qPage.getLimit());
        QueryWrapper<Lunbotu> queryWrapper=new QueryWrapper<>();
        iPage = this.baseMapper.selectPage(iPage,queryWrapper);
        return ResultView.ok(iPage);
    }

    /**
     * 新增
     * @param obj
     * @return
     */
    @Transactional
    @Override
    public ResultView add(Lunbotu obj) {
        this.save(obj);
        return ResultView.ok();
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Transactional
    @Override
    public ResultView del(String id) {
        this.removeById(id);
        return ResultView.ok();
    }

    /**
     * 修改
     * @param obj
     * @return
     */
    @Transactional
    @Override
    public ResultView up(Lunbotu obj) {
        this.updateById(obj);
        return ResultView.ok();
    }



}
